﻿#pragma once

namespace sfw
{
    template<class iterator, class ref, class ptr>
    struct Reverse_iterator
    {
        iterator _it;
        typedef Reverse_iterator<iterator, ref, ptr> self;
        Reverse_iterator(iterator it)
            :_it(it)
        {}

        ref operator*()
        {
            iterator tmp = _it;
            return *(--tmp);
        }

        ptr operator->()
        {
            return &(*_it);
        }

        self& operator++()
        {
            --_it;
            return *this;
        }
        self operator++(int)
        {
            self tmp(_it);
            --_it;
            return tmp;
        }
        bool operator!=(const self& it)
        {
            return it._it != _it;
        }
    };

}
